package com.tanhua.manager.mp;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tanhua.domain.db.AnalysisByDay;
import com.tanhua.manager.mapper.AnalysisByDayMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author anshuai
 * @create 2021-02-21 17:30
 */
@Service
public class DemoAnalysisService extends ServiceImpl<AnalysisByDayMapper, AnalysisByDay> {

    public void testMpService(){

        //1. 查询一个
        // AnalysisByDay analysisByDay = query().eq("record_date", "2020-02-21").one();
        // System.out.println(analysisByDay);

        //2.查询多个
        List<AnalysisByDay> analysisByDayList = query().between("record_date", "2021-01-22", "2021-02-21").list();
        // for (AnalysisByDay analysis : analysisByDayList) {
        //     System.out.println(analysis);
        // }

        //3.查询数量
        Integer count = query().gt("record_date", "2021-02-21").count();
        System.out.println(count);

        //4. 数据统计
        // QueryWrapper<AnalysisByDay> wrapper = new QueryWrapper<>();
        // wrapper.select("id");
        // int count = count(wrapper);
        // System.out.println(count);

        //5. 新增数据
        AnalysisByDay analysisByDay = new AnalysisByDay();
        save(analysisByDay);
        // this.baseMapper.insert();

        //6. 调用自定义的方法
        // this.baseMapper.cumulativeUsers();


    }
}
